#include "fxcc/imgui/Editor.h"
#include "fxcc/core/graph/common/Texture2DJack.h"

using namespace fxcc::graph::common;

template<>
bool fxcc::imgui::Editor::Edit<Texture2DJack::Desc>(const std::string& r, Texture2DJack::Desc& inst)
{
    static const std::map<fxcc::graph::common::SamplerType, std::string> ls = {
             {fxcc::graph::common::SamplerType::_sampler_2d_default_,"_sampler_2d_default_"},
             {fxcc::graph::common::SamplerType::_sampler_cube_default_,"_sampler_cube_default_"},
             {fxcc::graph::common::SamplerType::_sampler_cube_mipmap_linear_,"_sampler_cube_mipmap_linear_"},
             {fxcc::graph::common::SamplerType::_sampler_2d_array_default,"_sampler_2d_array_default"},
             {fxcc::graph::common::SamplerType::_sampler_2d_nearest,"_sampler_2d_nearest"},
             {fxcc::graph::common::SamplerType::_sampler_2d_nearest_no_wrap,"_sampler_2d_nearest_no_wrap"},
             {fxcc::graph::common::SamplerType::_sampler_2d_nearest_repeat,"_sampler_2d_nearest_repeat"},
    };
    static std::map<Texture2DJack::Desc::Type, std::string> ls2 =
    {
        {Texture2DJack::Desc::Type::_WIC_, "WIC" },
        {Texture2DJack::Desc::Type::_DDS_, "DDS" },
        {Texture2DJack::Desc::Type::_AllOC_, "ALLOC" },

    };
    ComboEnumMap<Texture2DJack::Desc::Type>("Type", inst.m_Type, ls2);
    switch (inst.m_Type)
    {
    case Texture2DJack::Desc::Type::_WIC_:
        EditInst<ImageMipmap::Desc>("m_WICConfig", inst.m_WICConfig);
        break;
    case Texture2DJack::Desc::Type::_DDS_:
        EditInst<std::string>("m_DDSPath", inst.m_DDSPath);
        break;
    case Texture2DJack::Desc::Type::_AllOC_:
        EditInst<ImageMipmap::MipMapData>("alloc info", inst.m_MipmapData);
    default:
        break;

    }
    ComboEnumMap< fxcc::graph::common::SamplerType>("sampleType", inst.m_SampleType, ls);

    return false;
}

template<>
bool fxcc::imgui::Editor::Edit<fxcc::graph::common::Texture2DJack>(const std::string& r, fxcc::graph::common::Texture2DJack& inst)
{
    EditInst<fxcc::graph::common::Texture2DJack::Desc>("m_Desc", inst.m_Desc);

    if (ImGui::Button("Load"))
    {
        inst.Load();
    }

    ImGui::Image((ImTextureID)inst.GetTextureId(), { 200,200 });
    return false;
}